]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
screenShield: Fix pointer motion signal handler leak
authorRay Strode <rstrode@redhat.com>
Tue, 29 Sep 2020 02:28:08 +0000 (22:28 -0400)
committerRay Strode <rstrode@redhat.com>
Thu, 8 Oct 2020 13:46:12 +0000 (09:46 -0400)
The screen shield code listens for motion events on the stage
so that it can hide the pointer until the user moves the mouse.

Unfortunately, if the user never moves the mouse, the signal
handler connection gets leaked.

This commit makes sure the connection gets disconnected when the
shield goes away.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1459

js/ui/screenShield.js

index 9beece64655ad17e90ff7b4ca196c61eb01de538..fa3a7a81677779cdfb5263e641edff81b75f5e78 100644 (file)
@@ -336,6 +336,25 @@ var ScreenShield = class {
         }
     }
 
+    _showPointer() {
+        this._cursorTracker.set_pointer_visible(true);
+
+        if (this._motionId) {
+            global.stage.disconnect(this._motionId);
+            this._motionId = 0;
+        }
+    }
+
+    _hidePointerUntilMotion() {
+        this._motionId = global.stage.connect('captured-event', (stage, event) => {
+            if (event.type() === Clutter.EventType.MOTION)
+                this._showPointer();
+
+            return Clutter.EVENT_PROPAGATE;
+        });
+        this._cursorTracker.set_pointer_visible(false);
+    }
+
     _hideLockScreen(animate) {
         if (this._lockScreenState == MessageTray.State.HIDDEN)
             return;
@@ -364,7 +383,7 @@ var ScreenShield = class {
             this._hideLockScreenComplete();
         }
 
-        this._cursorTracker.set_pointer_visible(true);
+        this._showPointer();
     }
 
     _ensureUnlockDialog(allowCancel) {
@@ -435,15 +454,7 @@ var ScreenShield = class {
     }
 
     _lockScreenShown(params) {
-        let motionId = global.stage.connect('captured-event', (stage, event) => {
-            if (event.type() === Clutter.EventType.MOTION) {
-                this._cursorTracker.set_pointer_visible(true);
-                global.stage.disconnect(motionId);
-            }
-
-            return Clutter.EVENT_PROPAGATE;
-        });
-        this._cursorTracker.set_pointer_visible(false);
+        this._hidePointerUntilMotion();
 
         this._lockScreenState = MessageTray.State.SHOWN;